package org.prail.threads;

import java.io.IOException;

import javax.swing.JOptionPane;

import org.prail.net.Configuration;
import org.prail.net.core.Login;
import org.prail.ui.LoginFrame;
import org.prail.ui.Mp3Frame;

public class LoginThread extends Thread {
	
	private LoginFrame login;

	public LoginThread(LoginFrame login) {
		this.login = login;
	}
	
	@Override
	public void run() {
		try {
			if(!new Login(Configuration.username, Configuration.password).login()) {
				login.setLoginEnabled(true);
				JOptionPane.showMessageDialog(null, "Wrong username/password.\nPlease try again.");
				return;
			}
			login.dispose();
			new Mp3Frame().setVisible(true);
			Mp3Frame.setSearch(true);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
